<script setup lang="ts">
import { selectMapItem } from './core'
import type { MapItem } from '../types'

const props = defineProps<{
  txt: string
  item: MapItem<any> | ((txt: string) => MapItem<any>)
}>()

function jump() {
  let item: MapItem<any>
  if (typeof props.item === 'object') {
    item = props.item
  } else {
    item = props.item(props.txt)
  }
  selectMapItem(item.type, item.item, true)
}
</script>
<template>
  <div class="map-item-link" @click="jump()">
    <span class="map-hover">{{ txt }}</span>
  </div>
</template>
